<template>
  <div class="my">
    <div class="myinfo">
      <img @click="toLogin" :src="avator" alt="">
      <div @click="toLogin">
        <p>{{userInfo.nickName}}</p>
        <p v-if="userInfo.nickname">点击登录</p>
        <p v-else>VIP会员</p>
      </div>
    </div>
    <!-- <div class="iconlist">
      <div @click="goTo(item.url)" v-for="(item, index) in listData" :key="index">
        <span class="iconfont" :class="item.icon"></span>
        <span>{{item.title}}</span>
      </div>
    </div> -->
    <div class="order-box">
      <i-cell-group>
          <i-cell title="全部订单" is-link url="/pages/orderlist/main">
            <i-icon type="activity" slot="icon" size='18' color="pink"/>
          </i-cell>
      </i-cell-group>
      <div class="order-item" slot="footer">   
        <div class="item" @click="gotoOrder('init')">
          <i class="tn-icon-daifukuan" style="font-size:20px;"></i>
          待付款
        </div>  
        <div class="item" @click="gotoOrder('success')">
          <i class="tn-icon-daifahuo" style="font-size:20px;"></i>
          待发货
        </div>
        <div class="item" @click="gotoOrder('delivery')">
          <i class="tn-icon-yifahuo" style="font-size:20px;"></i>
          已发货
        </div>
        <div class="item" @click="gotoOrder('evaluation')">
          <i class="tn-icon-yiwancheng" style="font-size:20px;"></i>
          待评价
        </div>
      </div>
    </div>
    
    
    <view class="list-wrap">    
      <view class="list-item">
        <wxc-list
                v-for="item in list"
                :key="item"
                class="item"
                :title="item.title"
                :desc="item.slot? '' : item.desc"
                :mode="index == list.length-1 ? 'none': ''"
                :src="item.src" @click="goTo(item.url)">
          <view v-if="item.slot && item.desc" class="desc-highlight" @click="goTo(item.url)">{{item.desc}}</view>
        </wxc-list>
      </view>

      <view class="list-item">
        <wxc-list
                class="item"
                icon="help"
                icon-color="#69A0DD"
                title="客服与帮助" @click="getHelp">
        </wxc-list>
        <wxc-list
                class="item"
                icon="feedback"
                icon-color="#69A0DD"
                mode="none"
                title="意见反馈" @click="goTo('/pages/feedback/main')" ></wxc-list>
      </view>
    </view>

    <i-modal title="请选择联系方式" :visible="helpVisible" @click="handleClick" :show-ok='showbutton' :show-cancel='showbutton'>
        <!-- <view>请选择支付方式</view> -->
        <div class="help-box">
          <button type='primary' class="btn" @click="callPhone"> 电话联系 </button>
          <button type='primary' class="btn" open-type='contact'> 在线联系 </button>
          <button type="default" class="btn" @click="handleClick">取消</button>
        </div>

    </i-modal>
    
  </div>
</template>

<script>
  import {
    get,
    toLogin,
    login
  } from "../../utils";
  import  $Message from "../../../static/iview/base/index";
  export default {
    onShow() {
      // 可以通过 wx.getSetting 先查询一下用户是否授权了 "scope.record" 这个 scope
      if (login()) {
        this.userInfo = login();
        console.log(this.userInfo);
        this.avator = this.userInfo.avatarUrl;
      }
    },
    created() {},
    mounted() {},
    data() {
      return {
        avator: "http://yanxuan.nosdn.127.net/8945ae63d940cc42406c3f67019c5cb6.png",
        allcheck: false,
        listData: [],
        Listids: [],
        userInfo: {},
        list: [
          // {
          //     title: '打卡领红包',
          //   desc: '您有1个10元红包可领取',
          //   slot: false,
          //   src: 'https://s10.mogucdn.com/mlcdn/c45406/171226_2kall2je2079dh6ddkgc31d27cce2_38x38.png'
          // }, {
          //   title: '优惠券',
          //   desc: '满100减20',
          //   slot: true,
          //   src: 'https://s10.mogucdn.com/mlcdn/c45406/170603_7ida8bdc21j18b91aa2ii3lk38b9i_38x38.png'
          // }, {
          //   title: '钱和红包',
          //   desc: '',
          //   slot: false,
          //   src: 'https://s10.mogucdn.com/mlcdn/c45406/171011_0acg74g776ig2459c1c6gkge07hch_40x40.png'
          // },
           {
            title: '企业简介',
            desc: '官方',
            slot: true,
            src: 'https://s10.mogucdn.com/mlcdn/c45406/170603_0ea73id6h6926k281cdhia0dg5gdg_38x38.png',
            url:'/pages/brief/main'
          }, 
          {
            title: '我的收藏',
            desc: '',
            slot: true,
            src: 'https://s10.mogucdn.com/mlcdn/c45406/170603_6h37fg4074i3a2l2gb92dbbc15k84_38x38.png',
            url:'/pages/collectlist/main'
          }, 
          // {
          //   title: '足迹',
          //   desc: '',
          //   slot: false,
          //   src: 'https://s10.mogucdn.com/mlcdn/c45406/170603_00di1ei7f095j8b996icg79kl91kc_38x38.png'
          // }, {
          //   title: '我的拼团',
          //   desc: '',
          //   slot: false,
          //   src: 'https://s10.mogucdn.com/mlcdn/c45406/170603_55gkg003el4k2jbg2d2ieh030fjcf_38x38.png'
          // },
           {
            title: '地址管理',
            desc: '收货地址',
            slot: false,
            src: 'https://s10.mogucdn.com/mlcdn/c45406/180109_26hggaiha8k7blig5k4ihk5k967ii_38x38.png',
            url:'/pages/address/main'
          }]
      ,
      helpVisible:false,
      actions:[
         {
                name: '电话联系',
                color: '#2d8cf0',
                id:1,
            },
            {
                name: '在线联系',
                color: '#19be6b',
                id:2,
            },
            {
                name: '取消',
                id:3
            }
        ]
      ,
      showbutton:false};

    },
    components: {},
    methods: {
      goTo(url) {        
        if (toLogin()) {
          wx.navigateTo({
            url: url
          });
        }
      },
      gotoOrder(type){
        console.log(type)
        if (toLogin()) {
          wx.navigateTo({
            url: '/pages/orderlist/main?type='+type
          });
        }
      },
      toLogin() {
        if (!this.userInfo.avatarUrl) {
          wx.navigateTo({
            url: "/pages/login/main"
          });
        }
      },
      getHelp(){
        this.helpVisible = true
      },
      handleClick (target ) {

       this.helpVisible = false
    },
    callPhone(){
     wx.makePhoneCall({
        phoneNumber: '+8618010620509' // 仅为示例，并非真实的电话号码
      })
    }

    },
    computed: {}
  };

</script>
<style lang='scss' scoped>
  @import "./style";

</style>
